home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 38 / sgn_bans.zip / TRIM.PAS < prev   
Pascal/Delphi Source File  |  1985-10-30  |  611b  |  25 lines

  1. function Trim(Var StrInput ) : Integer ;
  2.  
  3.   {Trims string, returns trimmed length}
  4.  
  5. Var
  6.   Str : string[255] absolute StrInput ;
  7.   m, n : integer ;
  8.  
  9.   {m is a pointer into the string, and moves forwards from the end.}
  10.  
  11.   {n is (1) the position of the last non-space, and }
  12.   {     (2) if <> 0, a flag that a non-space has been found.}
  13.  
  14. begin
  15.   m := Ord(Str[0]) ;   {get current length of string}
  16.   n := 0 ;
  17.   while ( m > 0 )  and ( n = 0 ) do
  18.   begin
  19.     if Str[m] <> ' ' then n := m
  20.     else Str[0] := Pred(Str[0]) ;  {reduce size in byte 0}
  21.     m := m - 1 ;
  22.   end ;
  23.   Trim := n ;
  24. end ;
  25.